Use precise frequency for TX SYNC messages#13
Open
comio wants to merge 6 commits intorichardcochran:masterfrom
Open
Use precise frequency for TX SYNC messages#13comio wants to merge 6 commits intorichardcochran:masterfrom
comio wants to merge 6 commits intorichardcochran:masterfrom
Conversation
This patch avoid to block on a timer fd read. We already protect with poll().
Change fd[0] with FD_EVENT and fd[1] with FD_GENERAL.
This change ensure that all timers timeouts are handled just before the PTP message handling. The PTP message hanlding code can performe timerfd_settime() calls that invalidate the status of timer descriptors. This side effect is not noticed until now because we never read from the timer descriptors.
After the timer expiration, just after the poll(), we can read fron the timer file descriptor a 64bit value that represents the number of expirations that have occured. This value is useful for debug. In addition, when we use a periodic timer the timer will be locked until the read of this value.
During a timer handling we should avoid to call timerfd_settime() on a different timer because this call will invalidate the file descriptor, resulting in a EGAIN when the other timer code will performe the read(). The ANNOUNCE and RX SYNC timer code just doesn't follow this rule. The solution is to split the rearm code.
In order to obtain a precise TX SYNC frequency we need to use a periodic timer facility instead to reconfigure the timer on every expiration. The solution consists to configure the it_interval field of the itimerspec structure (see timerfd_create(2) man page) only when the port goes into Master role and avoiding to call timerfd_settime() on timer expiration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The actual ptp4l implementation rearms timers after the expiration. This approach doesn't permit to have a precise TX SYNC message scheduling.
During my test the TX SYNC frequency is slightly lower the expectation (eg 15.99Hz vs 16Hz).
The following patchset uses non blocking timers and only for TX SYNC timer implements a precise periodic timer.
Before to enable the periodic timer we have to:
History:
v4 Pass sanity test
v3 Small review